<template>
	<a-button style="margin: 0 8px;width: 100px;" type="primary" ghost @click="jumpToReagent()" >返回</a-button>
	<a-card :bordered="false">
		<s-table
			id="printTable"
			ref="table"
			:columns="columns"
			:data="loadData"
			:alert="options.alert.show"
			bordered
			:row-key="(record) => record.id"
			:tool-config="toolConfig"
			:row-selection="options.rowSelection"
		>
			<template #bodyCell="{ column, record }">
				<template v-if="column.dataIndex === 'bioCabinetDoorName'">
					{{record.bioCabinetName}}-{{record.bioCabinetDoorName}}
				</template>
				<template v-if="column.dataIndex === 'curCabinetDoorName'">
					{{record.curCabinetName}}-{{record.curCabinetDoorName}}
				</template>
				<template v-if="column.dataIndex === 'goodsName'">
					<a-space>
						<a-tag v-if="record.unknownFlag === 1" color="red">未知</a-tag>
						<span v-else>{{ record.goodsName }}</span>
					</a-space>
				</template>
				<template v-if="column.dataIndex === 'leaveFlag'">
					<a-space>
						<a-tag v-if="record.leaveFlag === 0" color="green">在柜</a-tag>
						<a-tag v-if="record.leaveFlag === 1" color="red">离柜</a-tag>
					</a-space>
				</template>
				<template v-if="column.dataIndex === 'recognizeMethod'">
					<a-space>
						<a-tag v-if="record.rfidFlag === 1" color="purple" @click="recognizeMethodRef.onOpen(record)">
							RFID
						</a-tag>
						<a-tag v-if="record.qrcodeFlag === 1" color="cyan" @click="recognizeMethodRef.onOpen(record)">
							二维码
						</a-tag>
						<a-tag v-if="record.barcodeFlag === 1" color="blue" @click="recognizeMethodRef.onOpen(record)">
							条形码
						</a-tag>
					</a-space>
				</template>
				<template v-if="column.dataIndex === 'state'">
					<a-space>
						<a-tag v-if="record.state === 0" color="red">已报废</a-tag>
						<a-tag v-if="record.state === 1" color="green">启用</a-tag>
					</a-space>
				</template>
				<template v-if="column.dataIndex === 'handleExcCount'">
					<a-tag v-if="record.handleExcCount > 0" color="red" @click="jumpEventForExc(record.id)">
						{{record.handleExcCount}}
					</a-tag>
					<a-tag color="green" v-else>
						无
					</a-tag>
				</template>
				<template v-if="column.dataIndex === 'createUser'">
					<span v-if="record.createUserName">{{record.createUserName}}({{record.createUserAccount}})</span>
				</template>
				<template v-if="column.dataIndex === 'enterFlag'">
					<a-space>
						<a-tag v-if="record.enterFlag === 0" color="red">未入库</a-tag>
						<a-tag v-if="record.enterFlag === 1" color="green">已入库</a-tag>
					</a-space>
				</template>
			</template>
		</s-table>
	</a-card>
</template>
<style>
@media print{
	button {
		display: none !important;
	}
	@page {
		size: landscape; /* 设置纸张尺寸为 Tabloid */

	}
}
</style>
<script setup name="reagent-print">
import bizGoodsApi from "@/api/biz/bizGoodsApi";
import {useRouter} from "vue-router";

const columns = [
	{
		title: '试剂ID',
		dataIndex: 'id'
	},
	{
		title: '试剂名称',
		dataIndex: 'goodsName'
	},
	{
		title: 'CAS编码',
		dataIndex: 'reagentCasNo'
	},
	{
		title: '存放柜门',
		dataIndex: 'bioCabinetDoorName'
	},
	{
		title: '存放地点',
		dataIndex: 'bioCabinetLoationName'
	},
	{
		title: '当前柜门',
		dataIndex: 'curCabinetDoorName'
	},
	{
		title: '当前柜地点',
		dataIndex: 'curCabinetLoationName'
	},
	{
		title: '当前量(g)',
		dataIndex: 'reagentAvlWeight'
	},
	{
		title: '当前量(ml)',
		dataIndex: 'reagentAvlVolume'
	},
	{
		title: '是否在柜',
		dataIndex: 'leaveFlag'
	},
	{
		title: '识别方式',
		dataIndex: 'recognizeMethod'
	},
	{
		title: '待处理异常',
		dataIndex: 'handleExcCount'
	},
	{
		title: '新增用户',
		dataIndex: 'createUser'
	},
	{
		title: '状态',
		dataIndex: 'state'
	},
	{
		title: '入库情况',
		dataIndex: 'enterFlag'
	}
]
let searchFormState = reactive({
	goodsType: 1,
	size:100
})
const loadData = (parameter) => {
	return bizGoodsApi.bizGoodsPage(Object.assign(parameter, searchFormState)).then((data) => {
		return data
	})
}
const options = {
	alert: {
		show: false,
		clear: () => {
			selectedRowKeys = ref([])
		}
	},
	rowSelection: {
		onChange: (selectedRowKey, selectedRows) => {
			selectedRowKeys.value = selectedRowKey
		}
	}
}
const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
setTimeout(() => {
	window.print();
}, 1000)
const router = useRouter()

const jumpToReagent = () =>{
	router.push({ path:'reagent'})

}
</script>
